#!/usr/bin/python
# encoding: utf-8
'''
@File    :   code.py
@Time    :   2020/03/11 21:54:19
@Author  :   fangkaijin 
@Version :   1.0
@Contact :   fangkaijin@gmail.com
@License :   杭州移动互联
@Desc    :   None
'''

# 导入库包

import sys, os
import datetime
from time import strftime, localtime
import functools

#装饰器

#装饰器打印日志
def log(func):
    def wrapper(*args, **kwargs):
        print('call %s():' % func.__name__)
        return func(*args, **kwargs)
    return wrapper

@log
def now():
    print(datetime.datetime.now())
    return

@log
def now1():
    print(strftime('%Y-%m-%d %H:%M:%S', localtime()))


if __name__ == '__main__':
    n = now()
    n1 = now1()
    print(now.__name__)

def log(text):
    def decorator(func):
        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            print('%s %s():' % (text, func.__name__))
            return func(*args, **kwargs)
        return wrapper
    return decorator

@log("装饰器打印日志")
def now2():
    print(strftime('%Y-%m-%d %H:%M:%S', localtime()))
n2 = now2()

#便函数
print(int('123'))
int2 = functools.partial(int, base=10)
print(int2('123'))
# def int2(x):
#     return int(x, base=2)

print(int2('1000000', base=2))

print(int2('123'))
print(int2('123', base=8))


